/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package actuatedocumentor;

import java.io.Serializable;
import java.util.ArrayList;

/**
 *
 * @author Richard
 */
public class ActuateClass implements Serializable{

    private String classname;
    private String superclassname;
    private OrderedHashMap methods;
    private String classIdentifier;
    
    
    public ActuateClass(String classname, String classIdentifier, String superClassName) {
        this.classIdentifier = classIdentifier;
        methods = new OrderedHashMap();
        this.classname = classname;
        this.superclassname = superClassName;
        
    }
    
    public ActuateClass(){
        classIdentifier = "";
        methods = new OrderedHashMap();
        
    }

    public void setMethods(OrderedHashMap methods) {
        this.methods = methods;
    }

    
    
    public int getMethodCount(){
        if(methods==null){
            return 0;
        }
        return methods.size();
    }
    
    
    public OrderedHashMap getMethods() {
        return methods;
    }

    public void setClassIdentifier(String classIdentifier) {
        this.classIdentifier = classIdentifier;
    }

    
    public String getSuperclassname() {
        return superclassname;
    }

    
    public String getClassname() {
        return classname;
    }

    public void setSuperclassname(String superclassname) {
        this.superclassname = superclassname;
    }

    public void addMethod(String name, String code){
        MethodDetails md = new MethodDetails(name, code);
        methods.put(md.getMethodName(), md);
    }

    public void setClassname(String classname) {
        this.classname = classname;
    }

    public String getClassIdentifier() {
        return classIdentifier;
    }

    @Override
    public String toString() {
        String returnValue = "";
        
        returnValue = "Class Name = "+this.getClassname()+
                "\n\r"+ "Superclass Name = " + this.getSuperclassname()+"\n\r"+
                "Class Identifier = "+ this.getClassIdentifier()+"\n\r"+
                "Class Method Count = "+ this.getMethodCount()+ "\n\r";
        
        OrderedHashMap ar = this.getMethods();
                
        ArrayList al = ((OrderedHashMap)ar.clone()).getArrayList();
        if(ar!=null){
            for(int i = 0; i<al.size();i++){
            //while(it.hasNext()){
              
            //for(int i = 0; i<ar.size(); i++){
                returnValue = returnValue + "Method Number = "+(i+1)+"\n\r"+ 
                    ((MethodDetails)al.get(i)).toString() + "\n\r";
            }
        }
                   
        return returnValue+"\n\r";
        
    }
    
    
}
